
// Copyright (C) 2007 Richard Uhler
// This file is part of Esiply.
//
// Esiply is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License, Version 2,
// as published by the Free Software Foundation.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.

#ifndef _NUMBER_H_
#define _NUMBER_H_

#include "Value.h"
#include "ValueType.h"

class Number : public Value
{
public:
    Number(const char* cstr, int length);
    Number(double value);

    virtual ValueType getType() const;
    virtual Boolean* toBoolean();
    virtual Object* toObject();
    virtual Number* toNumber();
    virtual String* toString();
    virtual Number* toInteger();
    virtual Number* toInt32();
    virtual Number* toUint32();
    virtual Number* toUint16();

    double get_value() const;

    // Operators
    static Number* multiply(Number* lhs, Number* rhs);
    static Number* divide(Number* lhs, Number* rhs);
    static Number* modulo(Number* lhs, Number* rhs);
    static Number* add(Number* lhs, Number* rhs);
    static Number* subtract(Number* lhs, Number* rhs);
    static Number* minus(Number* rhs);
    static Boolean* less_than(Number* lhs, Number* rhs);
    static Number* left_shift(Number* lhs, Number* rhs);
    static Number* right_shift(Number* lhs, Number* rhs);
    static Number* bitwise_and(Number* lhs, Number* rhs);
    static Number* bitwise_or(Number* lhs, Number* rhs);
    static Number* bitwise_xor(Number* lhs, Number* rhs);
    static Number* bitwise_not(Number* rhs);
    static Boolean* equals(Number* lhs, Number* rhs);
    static Number* unsigned_right_shift(Number* lhs, Number* rhs);

    // The Number Prototype
    static Object* prototype;

private:
    double m_value;
};

#endif//_NUMBER_H_

